package modeller.databasedesignmodel.servicedemand.transaction.sqlquery;

import modeller.databasedesignmodel.relation.Relation;
import modeller.databasedesignmodel.servicedemand.IServiceDemand;

/**
 * Created by:  Jason Ye
 * Date:        24/03/2012
 * Time:        09:31
 */
public class SQLQueryServiceDemand implements IServiceDemand {

    private double serviceDemand;
    private Relation relation;


    public SQLQueryServiceDemand(double serviceDemand, Relation relation) {
        this.serviceDemand = serviceDemand;
        this.relation = relation;
    }

    @Override
    public String myToString() {

        return "Demand on relation " + relation.getRelationName() + " = " + serviceDemand + "\n";

    }

    @Override
    public double getServiceDemandForRelation(Relation r) {
        return (r.getRelationName().equals(relation.getRelationName())) ? serviceDemand : 0;
    }

    public double getServiceDemand() {
        return serviceDemand;
    }

    public void setServiceDemand(double serviceDemand) {
        this.serviceDemand = serviceDemand;
    }

    public Relation getRelation() {
        return relation;
    }

    public void setRelation(Relation relation) {
        this.relation = relation;
    }
}
